package com.hnzq.cloud.exception;

import com.hnzq.cloud.model.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@ResponseBody
public class FreExceptionHandler {


    //父异常
    @ExceptionHandler(FreshException.class)
    public Result DefectTrackingException(FreshException e){
        return Result.newInstance().setMessage(e.getMessage()).setCode(e.getCode());
    }


    //兜底操作
    @ExceptionHandler(Exception.class)
    public Result Exception(Exception e){
        e.printStackTrace();
        return Result.newInstance().setMessage("有异常").setCode(500);
    }

}
